<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <a-input placeholder="请输入项目名称" v-model="queryParam.projectName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="进场状态">
              <j-dict-select-tag
                placeholder="请选择进场状态"
                v-model="queryParam.entryStatus"
                dictCode="gc_project_entry_status"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{ x: true }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <template v-if="record.entryStatus == 1">
            <!-- <a-popconfirm title="确定通过吗?" @confirm="() => handleAudit(record, 2)">
              <a>通过</a>
            </a-popconfirm>
            <a-divider type="vertical" />
            <a-popconfirm title="确定驳回吗?" @confirm="() => handleAudit(record, 3)">
              <a>驳回</a>
            </a-popconfirm> -->
            <a @click="goAudit(record.id)">审批</a>
            <a-divider type="vertical" />
          </template>
          <a @click="handleDetail(record)">详情</a>
        </span>
      </a-table>
    </div>

    <gc-project-entry-modal ref="modalForm" @ok="modalFormOk" />
    <audit-modal ref="auditModal" @ok="doAudit" ></audit-modal>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import GcProjectEntryModal from './modules/GcProjectEntryModal'
import AuditModal from '@/views/exOperationRecord/AuditModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import '@/assets/less/TableExpand.less'
import { httpAction, getAction } from '@/api/manage'

export default {
  name: 'GcProjectEntryList',
  mixins: [JeecgListMixin],
  components: {
    GcProjectEntryModal,
    AuditModal,
  },
  data() {
    return {
      description: '项目进场审核页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '招标人',
          align: 'center',
          dataIndex: 'zbr',
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
        },
        {
          title: '项目编号',
          align: 'center',
          dataIndex: 'projectCode',
        },
        {
          title: '项目类型代码',
          align: 'center',
          dataIndex: 'xmlxdm_dictText',
        },
        {
          title: '工程类别',
          align: 'center',
          dataIndex: 'gclb_dictText',
        },
        {
          title: '本次招标投资额(万元)',
          align: 'center',
          dataIndex: 'bczbtzew',
        },
        {
          title: '进场状态',
          align: 'center',
          dataIndex: 'entryStatus_dictText',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/gcProject/gcProjectEntry/auditList',
        audit: 'gcProject/gcProjectEntry/audit',
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: {
        entryStatus: '1',
      },
      visible: false,
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'zbr', text: '招标人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zblxr', text: '招标联系人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zbdwdz', text: '单位地址', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zblxfs', text: '联系方式', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zbdzyx', text: '电子邮箱', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'xmszqy',
        text: '项目所在区域(字典：sys_kf_area)',
        dictCode: 'sys_kf_area',
      })
      fieldList.push({
        type: 'string',
        value: 'xmhyfl',
        text: '项目行业分类（字典：sys_industry_category）',
        dictCode: 'sys_industry_category',
      })
      fieldList.push({ type: 'string', value: 'projectName', text: '项目名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'projectCode', text: '项目编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'jddw', text: '监督单位', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zdxm', text: '重点项目(1是0否)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'xmlxdm', text: '项目类型代码', dictCode: 'sys_project_type' })
      fieldList.push({ type: 'string', value: 'xmyzmc', text: '项目业主名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'czbl', text: '出资比例', dictCode: '' })
      fieldList.push({ type: 'string', value: 'xmdz', text: '项目地址', dictCode: '' })
      fieldList.push({
        type: 'string',
        value: 'tzzt',
        text: '投资主体(字典：sys_investment_subject)',
        dictCode: 'sys_investment_subject',
      })
      fieldList.push({ type: 'string', value: 'gclb', text: '工程类别', dictCode: 'sys_engineering_type' })
      fieldList.push({
        type: 'string',
        value: 'jkxs',
        text: '价款形式(字典：sys_price_type)',
        dictCode: 'sys_price_type',
      })
      fieldList.push({ type: 'string', value: 'tzzew', text: '投资总额(万元)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bczbtzew', text: '本次招标投资额(万元)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zjly', text: '资金来源', dictCode: '' })
      fieldList.push({ type: 'string', value: 'jhlxpwh', text: '计划立项批文号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zjdwqk', text: '资金到位情况', dictCode: '' })
      fieldList.push({ type: 'string', value: 'shbmmc', text: '审核部门名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'shbmdm', text: '审核部门代码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'sjdw', text: '设计单位', dictCode: '' })
      fieldList.push({ type: 'string', value: 'jsydpwh', text: '建设用地批文号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'sjwjpzsh', text: '设计文件批准书号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'qtzxpzwh', text: '其他专项批准文号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'xmgm', text: '项目规模', dictCode: '' })
      fieldList.push({ type: 'string', value: 'xmpwmc', text: '项目批文名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'sfgdtzxm', text: '是否固定投资项目(1是0否)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tzxmtydm', text: '投资项目统一代码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'tzxmmc', text: '投资项目名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'xmpzdw', text: '项目批准单位', dictCode: '' })
      fieldList.push({ type: 'date', value: 'basj', text: '备案时间' })
      fieldList.push({ type: 'date', value: 'slsj', text: '受理时间' })
      fieldList.push({ type: 'string', value: 'zbfs', text: '招标方式(1公开招标)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'xmpzwh', text: '项目批准文号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zbzzf', text: '招标组织方(1委托代理)', dictCode: '' })
      fieldList.push({ type: 'string', value: 'dljg', text: '代理机构', dictCode: '' })
      fieldList.push({ type: 'string', value: 'dljgfzr', text: '代理机构负责人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'dllxr', text: '代理联系人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'dllxdh', text: '代理联系电话', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zbfw', text: '招标范围', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zbbz', text: '备注', dictCode: '' })
      fieldList.push({ type: 'string', value: 'zbxmbab', text: '招标项目备案表', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bzjdsdtwth', text: '保证金代收代退委托函', dictCode: '' })
      fieldList.push({ type: 'string', value: 'kfsbyjcns', text: '开封市公共资源交易领域"八严禁"承诺书', dictCode: '' })
      fieldList.push({ type: 'string', value: 'attachment', text: '附件', dictCode: '' })
      fieldList.push({ type: 'string', value: 'entryStatus', text: '进场状态', dictCode: 'gc_project_entry_status' })
      fieldList.push({ type: 'int', value: 'version', text: '版本号', dictCode: '' })
      this.superFieldList = fieldList
    },
    searchReset() {
      this.queryParam = { entryStatus: '1' }
      this.loadData()
    },
    goAudit(id) {
      var that = this
      that.$refs.auditModal.show(id)
    }, 
    doAudit(param) {
       var that = this
       that.confirmLoading = true;
       httpAction(this.url.audit, { id: param.entryId, entryStatus: param.operateResult, operateOpinion: param.operateOpinion }, 'post')
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>